{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-content">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">添加单个充值卡</li>
                <li>添加多个充值卡</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show  layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">卡号：</label>
                            <div class="layui-input-block">
                                <input type="text" name="number" lay-verify="required|number" placeholder="充值卡号" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">密码：</label>
                            <div class="layui-input-block">
                                <input type="text" name="password" lay-verify="required" placeholder="充值密码" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">额度：</label>
                            <div class="layui-input-block">
                                <input type="text" name="sum" lay-verify="required" placeholder="积分额度" class="layui-input " oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">地区：</label>
                            <div class="layui-input-block">
                                <select name="area" lay-verify="required" lay-search="">
                                    <option value="">请选择地区</option>
                                    {if !empty($data)}
                                    {foreach name="data" item="vo"}
                                    <option value="{$vo.district_id}" >{$vo.district}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item  layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">生成数量：</label>
                            <div class="layui-input-block">
                                <input type="text" name="set" lay-verify="required|number" placeholder="生成数量" class="layui-input " maxlength="5">
                            </div>
                        </div>
                        <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
                            <!--<label class="layui-form-label">密码：</label>-->
                            <!--<div class="layui-input-block">-->
                                <!--<input type="text" name="password" lay-verify="required" placeholder="充值密码" class="layui-input ">-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">额度：</label>
                            <div class="layui-input-block">
                                <input type="text" name="sum" lay-verify="required" placeholder="积分额度" class="layui-input " oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">地区：</label>
                            <div class="layui-input-block">
                                <select name="area" lay-verify="required" lay-search="">
                                    <option value="">请选择地区</option>
                                    {if !empty($data)}
                                    {foreach name="data" item="vo"}
                                    <option value="{$vo.district_id}" >{$vo.district}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('cardAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Card/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>